package zeebe.gateway.EventBased;

import io.zeebe.client.ZeebeClient;

public class EventBasedGatewayDeploy {
    public static void main(String[] args) {
        System.out.println("创建Zeebe的连接");
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("部署工作流");
        String bpmnPath = "bpmn/eventBasedGateway.bpmn";
        client.newDeployCommand()
                .addResourceFromClasspath(bpmnPath)
                .send()
                .join();

        System.out.println("部署MsgJobWorker");
        String msgType = "msg";
        MsgJobWorkerHandler msgHandler = new MsgJobWorkerHandler(client);
        client.newWorker()
                .jobType(msgType)
                .handler(msgHandler)
                .open();

        System.out.println("部署timerJobWorker");
        String timerType = "timer";
        TimerJobWorkerHandler timerHandler = new TimerJobWorkerHandler(client);
        client.newWorker()
                .jobType(timerType)
                .handler(timerHandler)
                .open();
    }
}
